package com.kinghood.productcenter.common.model.vo.product;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * description
 *
 * @author zhangFanJun
 * @date 2024-01-17 14:19
 **/
@Data
public class GetUserSearchSettingVO implements Serializable {

    private List<SearchSettingVO> searchList;
    private List<SearchSettingVO> showList;

    public void handleEmpty(){
        if(CollectionUtils.isEmpty(searchList)){
            searchList = null;
        } else {
            long aNull = searchList.stream().filter(x -> Objects.equals("null", x.getCode())).count();
            if(aNull > 0){
                searchList = Collections.emptyList();
            }
        }
        if(CollectionUtils.isEmpty(showList)){
            showList = null;
        } else {
            long aNull = showList.stream().filter(x -> Objects.equals("null", x.getCode())).count();
            if(aNull > 0){
                showList = Collections.emptyList();
            }
        }
    }
}
